﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace GameListCreator.Extenders
{
    public static class UserControlExtender
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userControl"></param>
        /// <returns></returns>

        public static Window GetWindow(this UserControl userControl)
        {
            DependencyObject dpParent = userControl.Parent;   
            do   
            {   
                dpParent = LogicalTreeHelper.GetParent(dpParent);   
            } while (dpParent.GetType().BaseType != typeof(Window));   
            
            return dpParent as Window;
        }
    }
}
